#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>

struct TreeNode
{
	char val;
	struct TreeNode* left;
	struct TreeNode* right;
};

struct TreeNode* TreeRebuild(char* src, int* pi)
{
	if (src[*pi] == '#')
	{
		(*pi)++;
		return NULL;
	}

	struct TreeNode* root = (struct TreeNode*)malloc(sizeof(struct TreeNode));
	root->val = src[(*pi)++];
	root->left = TreeRebuild(src, pi);
	root->right = TreeRebuild(src, pi);
	return root;
}

void InOrder(struct TreeNode* root)
{
	if (root == NULL)
		return;

	InOrder(root->left);
	printf("%c ", root->val);
	InOrder(root->right);
}

int main()
{
	char src[100];
	scanf("%s", src);
	int i = 0;
	struct TreeNode* root = TreeRebuild(src, &i);
	InOrder(root);

	return 0;
}